package com.ecplatform.common.utils;

import lombok.RequiredArgsConstructor;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class PasswordEncryptionUtil {

    private final BCryptPasswordEncoder bCryptPasswordEncoder;

    // 加密密码
    public String encryptPassword(String password) {
        return bCryptPasswordEncoder.encode(password);
    }

    // 验证密码
    public boolean verifyPassword(String rawPassword, String encodedPassword) {
        return bCryptPasswordEncoder.matches(rawPassword, encodedPassword);
    }
}
